package com.xms.sdk.core;

import com.xms.schema.entity.Attribute;
import com.xms.sdk.core.query.QueryBase;
import com.xms.security.entity.RoleEntityPermission;
import com.xms.security.identity.ICurrentUser;

import java.util.List;

/**
 * <p>
 * 查询参数集合
 * </p>
 *
 * @author migo
 * @since 2021/11/2
 */
public class RetrieverParameter {
    public static RetrieverParameter build(QueryBase query, ICurrentUser currentUser) {
        return new RetrieverParameter().setQuery(query).setCurrentUser(currentUser);
    }

    public QueryBase getQuery() {
        return query;
    }

    public RetrieverParameter setQuery(QueryBase query) {
        this.query = query;
        return this;
    }

    public ICurrentUser getCurrentUser() {
        return currentUser;
    }

    public RetrieverParameter setCurrentUser(ICurrentUser currentUser) {
        this.currentUser = currentUser;
        return this;
    }

    public boolean isIgnorePermissions() {
        return ignorePermissions;
    }

    public RetrieverParameter setIgnorePermissions(boolean ignorePermissions) {
        this.ignorePermissions = ignorePermissions;
        return this;
    }

    public List<Attribute> getNoneReadFields() {
        return noneReadFields;
    }

    public RetrieverParameter setNoneReadFields(List<Attribute> noneReadFields) {
        this.noneReadFields = noneReadFields;
        return this;
    }

    public List<RoleEntityPermission> getEntityPermissions() {
        return entityPermissions;
    }

    public RetrieverParameter setEntityPermissions(List<RoleEntityPermission> entityPermissions) {
        this.entityPermissions = entityPermissions;
        return this;
    }

    public boolean isIncludeNameField() {
        return includeNameField;
    }

    public RetrieverParameter setIncludeNameField(boolean includeNameField) {
        this.includeNameField = includeNameField;
        return this;
    }

    private QueryBase query;
    private boolean ignorePermissions = false;
    private boolean includeNameField = true;
    private ICurrentUser currentUser;
    private List<Attribute> noneReadFields;
    private List<RoleEntityPermission> entityPermissions;
}
